package com.serkol.ams.controller.api;

import com.serkol.ams.bean.Result;
import com.serkol.ams.entity.AppBrowser;
import com.serkol.ams.service.AppBrowserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("api/browser")
public class AppBrowserApiController {
    @Autowired
    private AppBrowserService appBrowserService;

    //browser
    @PostMapping("/getHardWare")
    private Result getHardWare(@RequestBody AppBrowser appBrowser) {
       // System.out.println(data);
      //  AppBrowser appBrowser = data.toJavaObject(AppBrowser.class);
        System.out.println(appBrowser);
        AppBrowser valid = appBrowserService.findByHash(appBrowser.getVhash());
        if (valid!=null) {
            if (valid.getStatus() == 1) {
                return Result.ok("待审核");
            } else {
                return Result.failure("待审核");
            }
        } else {
            appBrowserService.save(appBrowser);
            return Result.failure(1104, "未注册");
        }


    }

    @GetMapping("/getUrl")
    private Result getUrl() {

        Map<String, Object> sys = new HashMap<>();
        sys.put("url_1", "https://wxserkol.serkol.cn/");
        sys.put("url_2", "https://wxserkol.serkol.cn/");
        return Result.ok(sys);
    }
}
